package com.polytech.business;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import com.polytech.beans.Car;
import com.polytech.beans.ListCars;
import com.polytech.dao.CarDao;
import com.polytech.utils.BusinessFactory;

public class DefaultSearchEngine implements SearchEngine {

	
	
	@Override
	public List<Car> search(HashMap<String, Object> request) {
		CarsManager carManager=BusinessFactory.getCarsManager();
		
		Request request1=new Request();
		
		request1.put("minPrice", request.get("minPrice"));
		request1.put("maxPrice", request.get("maxPrice"));
		request1.put("model", carManager.findModel((String)request.get("model")));
		request1.put("category", carManager.findCategory((String)request.get("category")));
		request1.put("brand", carManager.findBrand((String)request.get("brand")));
		request1.put("color", carManager.findColor((String)request.get("color")));
		
		ListCars list=new ListCars(request1, carManager.getNonBookedCars());
		
		return list.getCarsSoted(6);
	}

}
